<template>
  <VSelects v-bind="$attrs" :dataSourse="allList" />
</template>

<script setup>
import { getOption } from "@/api/index.js";
//获取所有数据
const emit = defineEmits(["getOpts"]);
const props = defineProps({
  params: {
    type: String, //params
    default: undefined,
  },
});
const allList = computed(() => {
  return options.value;
});
onMounted(() => {
  getList();
});
const options = ref([]);
async function getList() {
  options.value = [];
  try {
    if(!props.params) return;
    const { data } = await getOption({ enums: props.params });
    options.value = data[props.params] || {};
    emit("getOpts", options.value);
  } catch (error) {
    console.error("An error occurred:", error);
  }
}
</script>

<style scoped></style>
